﻿using System;
using System.Collections.Generic;
using sinetd.Utilities;

namespace ClientCLI
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "ClientCLI [sinetd]";

            sinetd.Client.ConfigurationFile = "ClientCLI.config.xml";
            List<string[]> list = sinetd.Client.GetServices();
            list.Insert(0, new string[] { "index", "Service", "Protocol", "Configuration" });

            int index = -1;

            while (index != 0)
            {
                Console.Clear();

                Console.Write(list.PrintTable());
                
                do Console.Write("Choose [0 - exit]: "); while (!int.TryParse(Console.ReadLine(), out index));

                if (0 < index && index < list.Count)
                {
                    Console.Write(sinetd.Client.Send(index, Console.ReadLine()/* + "\r\n"*/));
                    Console.ReadLine();
                }
            }
        }
    }
}
